/*
 * @Author: Kilims Ye
 * @LastEditors: Kilims Ye
 * @Date: 2020-06-28 09:02:41
 * @LastEditTime: 2021-04-28 18:58:53
 * @Description:
 */
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import * as serviceWorker from "./serviceWorker";
import { AppProvider } from "@context/appContext";
import { Toast } from "antd-mobile";
import { message } from "antd";
import { AliveScope } from "react-activation";
import FastClick from "@utils/fastclick";
import { ThemeProvider } from "styled-components";
import { ErrorBoundary } from "react-error-boundary";
import ErrorFallback from "@components/ErrorFallback";
import Routes from "@routes";
import "lib-flexible";


FastClick.attach(document.body);

ReactDOM.render(
  <ErrorBoundary FallbackComponent={ErrorFallback}>
    <AppProvider>
      <AliveScope>
        <ThemeProvider
          theme={{
            btnBgImage: "linear-gradient(137deg, #ff5b5b 0%, #db0113 100%)",
          }}
        >
          <Routes />
        </ThemeProvider>
      </AliveScope>
    </AppProvider>
  </ErrorBoundary>,
  document.getElementById("root")
);

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
Toast.config({
  duration: 2,
  mask: false,
});
message.config({
  maxCount: 1,
  duration: 2,
});
serviceWorker.unregister();
